//Khai bao thu vien
#include<conio.h>
#include<stdio.h>
//Ham ve hinh chu nhat dac
void hcnd(int dai, int rong)
{
	int i,j;
	clrscr();
	for (i=1;i<=rong;i++)
	{
		gotoxy(39,2+i);
		for (j=1;j<=dai;j++)
			printf("*");
	}
}
//Ham ve hinh chu nhat rong
void hcnr(int dai,int rong)
{
	int i,j;
	clrscr();
	for (i=1;i<=rong;i++)
	{
		gotoxy(39,2+i);
		if((i==1)||(i==rong))
		{
			for (j=1;j<=dai;j++)
				if(j==dai-1)
					printf(" ");
				else
					printf("*");
		}
		else
		{
			 for(j=1;j<=dai;j++)
			 {
				if (j==1||j==dai)
					printf("*");
				else
					printf(" ");
			 }
		}
	}
}
void menu(int&chon)
{
	printf("\n\t1.Ve hinh chu nhat dac");
	printf("\n\t2.Ve hinh chu nhat rong");
	printf("\n\t0.Thoat");
	printf("\n\tChon cong viec:");
	scanf("%d",&chon);
}
void main()
{
	//Khai bao bien
	int dai,rong,chon;
	//Xoa man hinh
	clrscr();
	printf("\n\tCHUONG TRINH VE HINH CHU NHAT");
	do
	{
		clrscr();
		menu(chon);
		switch(chon)
		{
			//Ve hinh chu nhat dac
			case 1:
				printf("\n\tNhap chieu dai hcn:");
				scanf("%d",&dai);
				printf("\n\tNhap chieu rong hcn:");
				scanf("%d",&rong);
				hcnd(dai,rong);
				break;
			//Ve hinh chu nhat rong
			case 2:
				printf("\n\tNhap chieu dai hcn:");
				scanf("%d",&dai);
				printf("\n\tNhap chieu rong hcn:");
				scanf("%d",&rong);
				hcnr(dai,rong);
				break;
		}
		getch();
	}
	while(chon!=0);
}
